//
//  DiscountCollectionViewCell.m
//  WhereToTravel
//
//  Created by dlios on 15/10/13.
//  Copyright © 2015年 zhoushengmin. All rights reserved.
//

#import "DiscountCollectionViewCell.h"

#define W self.contentView.frame.size.width
#define H self.contentView.frame.size.height

@implementation DiscountCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self createView];
        [[NSNotificationCenter defaultCenter] postNotificationName:@"night" object:nil];
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(night) name:@"night" object:nil];
    }
    return self;
}

- (void)createView {
    [super createView];
    self.upImageView = [[UIImageView alloc] init];
    [self.contentView addSubview:self.upImageView];
    
    self.mistLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:12];
    self.mistLabel.numberOfLines = 0;

    self.downLeftLabel.font = [UIFont systemFontOfSize:10];

    self.downRightLabel.font = [UIFont systemFontOfSize:10];
    self.downRightLabel.textAlignment = NSTextAlignmentRight;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    self.upImageView.frame = CGRectMake(W * 0.05, 0, W * 0.9, H * 0.7);
    self.mistLabel.frame = CGRectMake(W * 0.05, H * 0.7, W * 0.9, H * 0.25);
    self.downLeftLabel.frame = CGRectMake(W * 0.01, H * 0.95, W/2, H * 0.05);
    self.downRightLabel.frame = CGRectMake(W/2, H * 0.95, W/2 - 20, H * 0.05);
    
}

- (void)night {
    if ([SingletonNight shareSingletonNight].isSelete == YES) {
        self.mistLabel.textColor = [UIColor whiteColor];
        self.downLeftLabel.textColor = [UIColor whiteColor];
        self.downRightLabel.textColor = [UIColor whiteColor];
    }
    else {
        self.mistLabel.textColor = [UIColor blackColor];
        self.downLeftLabel.textColor = [UIColor blackColor];
        self.downRightLabel.textColor = [UIColor blackColor];
    }
}

- (void)dealloc {
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"night" object:nil];
}


@end
